// 新闻资讯动画效果
function initNews() {
    // 检查是否存在新闻相关元素
    const newsSection = document.querySelector('.news-section');
    if (!newsSection) {
        console.log('News section not found, skipping animation initialization');
        return;
    }

    console.log('News animation initialized');

    // 获取所有新闻卡片
    const newsCards = document.querySelectorAll('.news-center-card, .news-right-card');
    
    // 为每个卡片添加鼠标悬停效果
    newsCards.forEach(card => {
        card.addEventListener('mouseenter', function() {
            this.style.transform = 'translateY(-5px)';
            this.style.transition = 'transform 0.3s ease';
        });
        
        card.addEventListener('mouseleave', function() {
            this.style.transform = 'translateY(0)';
        });
    });

    // 获取主新闻图片区域
    const mainNews = document.querySelector('.news-main-left');
    if (mainNews) {
        mainNews.addEventListener('mouseenter', function() {
            this.querySelector('img').style.transform = 'scale(1.05)';
            this.querySelector('img').style.transition = 'transform 0.3s ease';
        });
        
        mainNews.addEventListener('mouseleave', function() {
            this.querySelector('img').style.transform = 'scale(1)';
        });
    }
}

// 确保在组件加载完成后执行
if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', initNews);
} else {
    initNews();
} 